home *** CD-ROM | disk | FTP | other *** search
/ PC-Blue - MS DOS Public Domain Library / PC-Blue MS-DOS Public Domain Library - NYACC.iso / vol086 / roff41.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-12-15  |  5.7 KB  |  160 lines

  1. /********************************************************/
  2. /*                            */
  3. /*            ROFF4, Version 1.60            */
  4. /*                            */
  5. /*(C) 1983,4 by Ernest E. Bergmann            */
  6. /*        Physics, Building #16            */
  7. /*        Lehigh Univerisity            */
  8. /*        Bethlehem, Pa. 18015            */
  9. /*                            */
  10. /* Permission is hereby granted for all commercial and    */
  11. /* non-commercial reproduction and distribution of this    */
  12. /* material provided this notice is included.        */
  13. /*                            */
  14. /********************************************************/
  15. /*Jan 8, 1984*/
  16. /********************************************************/
  17. /* March 1984  DeSmet C version */
  18. /* Henry Harpending*/
  19. /* Anthropology Department*/
  20. /* University of New Mexico*/
  21. /* Albuquerque, NM  87131*/
  22. /*   no restrictions */
  23. /*********************************************************/
  24. #include "a:roff4.h"
  25. /**********************************************************
  26. Removes white-space characters at start of string.
  27. ***********************************************************/
  28. skip_blanks ( string )
  29. char *string;    /* cursor to original string */
  30. {char *p;    /* cursor to 'final' string */
  31. for(p=string;*string==BLANK||*string==TAB||*string==NEWLINE;
  32.     string++);
  33. while(*(p++) = *(string++));
  34. }
  35. /*************************************************************/
  36. int comtyp (line)
  37. char *line;
  38. {char let1, let2;
  39. let1 = toupper( line[1] );
  40. let2 = toupper( line[2] );
  41.  
  42. if ( let1==COMMAND )        return( IG );
  43. if ( let1=='I' && let2=='G')    return( IG );
  44. if ( let1=='F' && let2=='I')    return( FI );
  45. if ( let1=='F' && let2=='O')    return( FO );
  46. if ( let1=='T' && let2=='I')    return( TI );
  47. if ( let1=='B' && let2=='P')    return( BP );
  48. if ( let1=='B' && let2=='R')    return( BR );
  49. if ( let1=='C' && let2=='E')    return( CE );
  50. if ( let1=='H' && let2=='E')    return( HE );
  51. if ( let1=='I' && let2=='N')    return( IN );
  52. if ( let1=='L' && let2=='S')    return( LS );
  53. if ( let1=='N' && let2=='F')    return( NF );
  54. if ( let1=='P' && let2=='L')    return( PL );
  55. if ( let1=='R' && let2=='M')    return( RM );
  56. if ( let1=='S' && let2=='P')    return( SP );
  57. if ( let1=='S' && let2=='T')    return( ST );
  58. if ( let1=='N' && let2=='E')    return( NE );
  59. if ( let1=='F' && let2=='F')    return( FF );
  60. if ( let1=='S' && let2=='C')    return( SC );
  61. if ( let1=='O' && let2=='W')    return( OW );
  62. if ( let1=='T' && let2=='S')    return( TS );
  63. if ( let1=='O' && let2=='H')    return( OH );
  64. if ( let1=='O' && let2=='F')    return( OF );
  65. if ( let1=='E' && let2=='H')    return( EH );
  66. if ( let1=='E' && let2=='F')    return( EF );
  67. if ( let1=='A' && let2=='B')    return( AB );
  68. if ( let1=='D' && let2=='B')    return( DB );
  69. if ( let1=='T' && let2=='C')    return( TC );
  70. if ( let1=='T' && let2=='R')    return( TR );
  71. if ( let1=='C' && let2=='F')    return( CF );
  72. if ( let1=='I' && let2=='C')    return( IC );
  73. if ( let1=='O' && let2=='U')    return( OU );
  74. if ( let1=='J' && let2=='U')    return( JU );
  75. if ( let1=='N' && let2=='J')    return( NJ );
  76. if ( let1=='F' && let2=='R')    return( FR );
  77. if ( let1=='W' && let2=='H')    return( WH );
  78. if ( let1=='E' && let2=='M')    return( EM );
  79. if ( let1=='D' && let2=='M')    return( DM );
  80. if ( let1=='D' && let2=='S')    return( DS );
  81. if ( let1=='R' && let2=='G')    return( RG );
  82. if ( let1=='D' && let2=='I')    return( DI );
  83. if ( let1=='E' && let2=='D')    return( ED );
  84. if ( let1=='S' && let2=='O')    return( SO );
  85. if ( let1=='P' && let2=='C')    return( PC );
  86. if ( let1=='S' && let2=='A')    return( SA );
  87. if ( let1=='B' && let2=='J')    return( BJ );
  88.  
  89. if ( let1=='M')
  90.       { if (let2=='1')        return( M1 );
  91.     if (let2=='2')        return( M2 );
  92.     if (let2=='3')        return( M3 );
  93.     if (let2=='4')        return( M4 );
  94.       }
  95. return( UNKNOWN );        /* no match */
  96. }
  97. /*************************************************************
  98. gets the number ( if any ) associated with any command 
  99. *************************************************************/
  100. int get_val ( line, typ )
  101. char *line, *typ;
  102. {int i;
  103. char local[ MAXLINE ];
  104. strcpy (local, line);    /* local copy */
  105. /* skip over the command line */
  106. for(i=1; local[i]!=' '&&local[i]!='\t'&&local[i]!='\n' ;i++);
  107.  
  108. skip_blanks (&local[i]);    /* find the number */
  109. *typ = local[i];    /* relative or absolute */
  110. if ( *typ=='+' || *typ=='-' )    i++;
  111. else if ( !isdigit( *typ ) )    return( NO_VAL );
  112. return ( atoi( &local[i] ));
  113. }
  114. /*************************************************************
  115.  sets a global parameter like SPVAL, PAGESTOP, etc.
  116.  Also checks that the new value is within the range of that 
  117.  parameter.  Assigns the default for that parameter if no value
  118.   is specified.
  119. *************************************************************/
  120. set ( param, val, arg_typ, defval, minval, maxval )
  121. int *param, val, defval, minval, maxval;
  122. char arg_typ;
  123. {if(val==NO_VAL) *param = defval;    /* defaulted */
  124. else if(arg_typ == '+') *param += val;    /* relative + */
  125. else if(arg_typ == '-')    *param -= val;    /* relative - */
  126. else    *param = val;            /* absolute */
  127. *param = min (*param,maxval);
  128. *param = max (*param, minval);
  129. if DEBUG fprintf(stderr,"\tSET *param = %d\n", *param);
  130. }
  131. /*************************************************************
  132.     end current filled line 
  133. **************************************************************/
  134. brk()
  135. {int l;
  136. if DEBUG fprintf(stderr,"brk: OUTBUF=<%s>\n", OUTBUF);
  137. if (OUTPOS) put(OUTBUF);
  138. OUTW=OUTPOS=OUTTOP=OUTBOT=OUTWRDS = 0;
  139. OUTBUF[0] = '\0';
  140. }
  141.  
  142. /**************************************************/
  143. initxu()    /*initialize underline,overstrike variables*/
  144. {    XCOL=UCOL=-1;
  145.     _setmem(&XBUF,LSZ,' ');
  146.     _setmem(&UBUF,LSZ,' ');
  147. }
  148. /****************************************/
  149. need(n)    /*test for space before footer*/
  150. int n;    /*whole lines*/
  151. {if (( VLINENO>=(BOTTOM-n) ) && (BOTTOM>=VLINENO) )
  152.     {space(HUGE); NEWPAG= ++CURPAG;
  153.     }
  154. }
  155. /****************************************/
  156. min(i,j) int  i,j;{return( (i<j)?i:j);}
  157.  
  158. max(i,j) int i,j;{return( (i>j)?i:j);}
  159.  
  160. abs(i) int i;{ return((i>=0)? i:-i);}